home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-10-24 | 1.9 KB | 90 lines | [UVtx/UVtl] |
- // This program demonstrates animating a picture using
- // the Curve command. While the picture is moving, the
- // program changes the 'move' parameter, to alternate
- // between moving above and under the background.
-
- Init()
-
- DefPicture()
-
- DrawRectangles()
-
- PrepareToMove()
-
- Curve Fx(t), 50*sin(t*(360/200))+40, t, -width()/2-30, width()/2+20
-
- ////////////////////////////////////////
-
- /////////////
- Function Init()
- above=0
- last_flip = 0
-
- ////////////////////
- Function DefPicture()
- Picture "MoveIt"
- Fill 1,30000,40000,50000
- Repeat 2
- Forward 30
- Right 45
- Forward 10
- Right 90
- Forward 10
- Right 45
-
-
- /////////////////////////
- Function DrawRectangles(x)
- Up
- Goto -width()/2, -55,0
- Down
- Fill 1,64926,65535,49999
- Forward width()
- Goto width()/2, -height()/2, 180
- Forward width()
- Repeat x,-width()/2+20, width()/2-20,100
- Rect(x)
-
- ///////////////
- Function Rect(X)
- Up
- w = random(5)+5
- Goto X-w,-100-last_flip*20,90
- last_flip = 1 - last_flip
- Down
- Repeat 2
- Fill 1+int(random(2)),random(60000),random(60000), random(60000)
- Forward 200
- Right 90
- Forward 2*w
- Right 90
- x1 = x()
- y1 = y()
- Fill 1,0,0,0
- Goto x1+40,y1-20,0
- Forward 2*w
- Goto x1+2*w,y1,0
-
-
- ///////////////////////////////////////
- Function PrepareToMove()
- Up
- Pen picture="MoveIt",speed=40
- Goto -width()/2-50,0,0
- Down
- last_flip = 0
-
- ////////////
- Function Fx(X)
- If last_flip = 0 // first time thru
- last_flip = X
- Return X
- dx = X - last_flip
- If (dx > 100)
- last_flip = X
- If above
- Pen move="above"
- Else
- Pen move="below"
- above = 1-above
- Return X